package com.qf.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect {
    Logger logger = Logger.getLogger(MyAspect.class);

    @Pointcut("execution(* com.qf.service.impl.*.*(..))")
    public void pointcut() {
    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint joinPoint) {

        try {
            logger.info("============before: =====" + joinPoint.getSignature().getName() + "==========");
            Object obj = joinPoint.proceed();//调用的核心业务
            logger.info("==========afterreturing:" + obj + "=======");
            return obj;
        } catch (Throwable e) {
            logger.info("============exception:" + e.getMessage() + "==========");
        } finally {
            logger.info("==============after over===================");
        }
        return null;
    }
}